export function getTimeString(second) {
    const h = Math.floor(second / 3600)
    const hRemainder = Math.floor(second % 3600)
    const m = Math.floor(hRemainder / 60)
    const s = Math.floor(hRemainder % 60)
    if(h > 0) {
        return `${h}小时${m}分钟${s}秒`
    }
    if(m > 0) {
        return `${m}分钟${s}秒`
    }
    return `${s}秒`
}

export function timestampToTime (time, type='m') {
    let date = new Date(time)
	let Y = date.getFullYear().toString().padStart(2,'0')
	let M = (date.getMonth() + 1).toString().padStart(2,'0')
	let D = date.getDate().toString().padStart(2,'0')
	var h = date.getHours().toString().padStart(2,'0')
	var m = ':' + date.getMinutes().toString().padStart(2,'0')
	var s = ':' + date.getSeconds().toString().padStart(2,'0')
	if(type === 'm')  return `${M}月${D}日 ${h}${m}${s}`
	if(type === 'y')  return `${Y}年${M}月${D}日`
	if(type === 'Mm')  return `${M}月${D}日 ${h}${m}`
}